(function(window,undefined){
	var Banner = {},
	indexPage = Banner.indexPage = {};

	var MAX = 5;
	var pointer = (Math.random()*MAX+1).toFixed(0), selector = '#mainBanner > img';
	
	Banner.setPointer = function(__pointer){
		pointer = __pointer;
	};
	
	/*pointer 값에 따라서 특정 기능 연결*/
	indexPage.mainBlock = function(){
		if(pointer == 1){
			$(selector).attr('src','images/mainbanner1.png');
			$(selector).off('click').on('click',function(){
				alert('준비중');
				Sns.bannerShareToFacebook('http://buzzbee.kr/gpark/guppiiweb_ver1/images/mainbanner1.png');
			});
		} else if(pointer == 2){
			$(selector).attr('src','images/mainbanner2.png');
			$(selector).off('click').on('click',function(){
				alert('준비중');
				Sns.bannerShareToFacebook('http://buzzbee.kr/gpark/guppiiweb_ver1/images/mainbanner2.png');
			});
		} else if(pointer == 3){
			$(selector).attr('src','images/mainbanner3.png');
			$(selector).off('click').on('click',function(){
				if (!Account.isLogin()) {
					alert(NEED_LOGIN_MESSAGE);
					location.href = "login.php";
					return;
				}
				location.href='cast_write.php';
			});
		} else if(pointer == 4){
			$(selector).attr('src','images/mainbanner4.png');
			$(selector).off('click').on('click',function(){
				alert('준비중');
				Sns.bannerShareToFacebook('http://buzzbee.kr/gpark/guppiiweb_ver1/images/mainbanner4.png');
			});
		} else if(pointer == 5){
			$(selector).attr('src','images/mainbanner5.png');
			$(selector).off('click').on('click',function(){
				sessionStorage.setItem('category_code','FO');
				location.href='store.php';
			});
		}
	};
	
	Banner.animation = function(){
		var _rand = (Math.random()*MAX+1).toFixed(0);
		if(_rand == pointer){
			_rand = (Math.random()*MAX+1).toFixed(0);
		}
		
		Banner.setPointer(_rand);
		$(selector).fadeOut(500,function(){
			indexPage.mainBlock();
			$(this).fadeIn(500);
		});
	};
	
	window.Banner = window.Banner || Banner;
})(window);
